package cn.gson.oasys.services.system.impl;

import cn.gson.oasys.model.dao.roledao.RolepowerlistDao;
import cn.gson.oasys.model.entity.role.Rolemenu;
import cn.gson.oasys.model.entity.user.User;
import cn.gson.oasys.services.system.MenuSysService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import javax.transaction.Transactional;
import java.util.List;

@Service
@Transactional
public class MenuSysServiceImpl implements MenuSysService {

    @Autowired
    private RolepowerlistDao rolePowerListDao;

    //记日志
    Logger log = LoggerFactory.getLogger(getClass());

    //查询该用户对应的权限菜单
    public void findMenuSys(HttpServletRequest request, User user){
        List<Rolemenu> oneMenuAll=rolePowerListDao.findbyparentxianall(0L, user.getRole().getRoleId(), true,true);
        List<Rolemenu> twoMenuAll=rolePowerListDao.findbyparentsxian(0L, user.getRole().getRoleId(), true,true);
        request.setAttribute("oneMenuAll", oneMenuAll);
        request.setAttribute("twoMenuAll", twoMenuAll);
    }

}
